<!--缺陷严重度管理组件 -->
<template>
  <div >
	<div>
		<el-input placeholder="关键词" v-model="keyword"style="width: 200px;"></el-input>
		<el-button type="primary" size="mini" @click="load" >搜素</el-button>
		<el-button type="primary" size="mini" @click="open" >添加</el-button>
	</div>
	 <el-table :data="datas"style="width: 100%" >
		<el-table-column type="selection"  ></el-table-column>
		<el-table-column prop="severityCode" label="严重程度Id"></el-table-column>
		<el-table-column prop="severityDesc" label="严重程度名"></el-table-column>
		<el-table-column prop="moduleState" :formatter="state"
		label="严重程度状态"></el-table-column>
		<el-table-column prop="createBy" label="程度创建人"></el-table-column>
		<el-table-column prop="createTime" label="程度创建时间"></el-table-column>
		<el-table-column prop="modifyBy" label="程度修改人"></el-table-column>
		<el-table-column prop="modifyTime" label="修改时间"></el-table-column>
	
		<el-table-column  label="操作">
			<template slot-scope="scope">
				<el-button type="primary" icon="el-icon-edit" size="mini"  
				@click="openchange(scope.row)" >修改</el-button>
				
			</template>
		</el-table-column>
	</el-table>
		<!-- 添加缺陷程度的方法 -->
	
		 <el-dialog title="添加缺陷严重度" :visible.sync="dialogTableVisible " >
		  <el-form  label-width="80px"  >
		    <el-form-item label="严重度描述">
		      <el-input v-model="addSeverityParam.severityDesc"></el-input>
		    </el-form-item>
		
		    <el-form-item label="创建人">
		      <el-input v-model="addSeverityParam.createBy"></el-input>
		    </el-form-item>
		    <el-form-item label="创建时间" >
				<el-date-picker  value-format="yyyy-MM-dd HH:mm:ss"type="date"
				 placeholder="选择日期" v-model="addSeverityParam.createTime">
		   
		 </el-date-picker>
		 </el-form-item>
		</el-form>
		   <div slot="footer" >
		         <el-button @click="dialogTableVisible=false">取 消</el-button>
		         <el-button type="primary" @click="addSeverity">提交</el-button>
		    </div>
		 </el-dialog>
		
		<!-- 修改缺陷类型的弹出框-->
		 <el-dialog title="修改缺陷类型" :visible.sync="changeTableVisible " >
		  <el-form  label-width="80px"  >
		    <el-form-item label="类型描述">
		      <el-input v-model="changeTypeParam.severityDesc"></el-input>
		    </el-form-item>
		
		    <el-form-item label="类型状态">
				  
		      <el-input v-model="changeTypeParam.moduleState" placeholder="0不可用 1 可用">
			  </el-input>
		    </el-form-item>
					 <el-form-item label="创建人">
					   <el-input v-model="changeTypeParam.createBy" 
					   :disabled="changeTypeParam.createBy !=null"></el-input>
					 </el-form-item>
		    <el-form-item label="创建时间" >
				<el-date-picker  value-format="yyyy-MM-dd HH:mm:ss" type="date"
				 placeholder="选择日期" 
						 :disabled="changeTypeParam.createTime!=null"
						  v-model="changeTypeParam.createTime">
						</el-date-picker>
					</el-form-item>
					<el-form-item label="修改人">
					  <el-input v-model="changeTypeParam.modifyBy"></el-input>
					</el-form-item>
					<el-form-item label="修改时间" >
						<el-date-picker  value-format="yyyy-MM-dd HH:mm:ss" type="date"
						 placeholder="选择日期" v-model="changeTypeParam.modifyTime">
						</el-date-picker>
					</el-form-item>
		</el-form>
		   <div slot="footer" >
		         <el-button @click="changeTableVisible=false">取 消</el-button>
		         <el-button type="primary" @click="changForm">提交</el-button>
		    </div>
		 </el-dialog>
		
		
  </div>
</template>

<script>
export default {
  name: 'ststem-defectseverity',
  data() {
  		return {
  			datas:[],
  			keyword:null,
  			dialogTableVisible:false,
			changeTableVisible:false,
  			addSeverityParam:{
  				severityDesc:null,
  				createBy:null,
  				createTime:null
  			},
  			changeTypeParam:{
  				severityCode:null,
  				severityDesc:null,
  				createBy:null,
  				createTime:null,
  				moduleState:null,
  				modifyBy:null,
  				modifyTime:null
  			}
  		}
  	},
  methods:{
	  openchange(row){
	  		  this.changeTableVisible=true;
	  		  this.changeTypeParam.severityCode=row.severityCode,
	  		  this.changeTypeParam.severityDesc=row.severityDesc,
	  		  this.changeTypeParam.createBy=row.createBy,
	  		  this.changeTypeParam.createTime=row.createTime,
	  		  this.changeTypeParam.moduleState=row.moduleState,
	  		  this.changeTypeParam.modifyBy=row.modifyBy,
	  		  this.changeTypeParam.modifyTime=modifyTime
	  		  
	  },
	  changForm(){
	  			  
	  		  this.$http.post("/severity/save",this.changeTypeParam).then(resp =>{
	  			  if(resp.data.flag==true){
	  				  this.changeTableVisible=false;
	  				  this.load();
	  			  }
	  		  })
	  },
	  state(row, column, cell){
	  		 if(cell==0){
	  		 	return "不可用";
	  		 }else if(cell==1){
	  		 	return "可用";
	  		 }
	  },
	  
	  load(){
	  		  const param= "?keyword="+this.keyword
	  		  this.$http.get("/severity/query"+param).then(resp =>{
	  			  console.log("vvvvvvvvvvv"+this.keyword)
	  			  if(resp.data.flag=true){
	  				  console.log(resp.data.data)
	  				  this.datas= resp.data.data;
	  			  }
	  		  })
	  },
	  open(){
	  		this. dialogTableVisible=true; 
	  },
	  addSeverity(){
	  		  this.$http.post("/severity/save",this.addSeverityParam).then(resp => {
	  			  if(resp.data.flag=true){
	  				  console.log("mmmm"+resp.data.data)
	  			  }
	  			  this.addSeverityParam={};
				 
	  		  })
			   this.dialogTableVisible=false;
	  		  this.load();
	  }
	  	 
	 
  },
  created() {
  	this.load();
  }
  
}
</script>
<style>
	
</style>

